<?php
/**
 * 测试 DB, 激动人心的时刻
 *     使用全局变量的方式存储配置信息不是很好, but now 我们既来之则安之.
 *
 * @filesource testDB.php
 * @package MagicDB
 * @subpackage test
 * @version $id: 0.1, utf8, Wed Dec 23 11:45:29 CST 2009
 * @author LD King <kldscs[at]gmail.com>
 * @copyright Copyleft (D.) 2007 - 2009 MiFunny China Inc.
 * @link http://mifunny.info/
 * @example 
 *   
 */

require_once '../DB.class.php';
$_config['MagicDB'] = array(
	'driver' => 'mysql',  //数据库驱动, 参看 http://www.php.net/manual/en/pdo.drivers.php
	'dsn' => 'mysql:dbname=test;host=127.0.0.1;port=3306',
	'username' => 'test', 
	'password' => '',
	'charset' => 'utf8',
	'collate' => 'utf8_general_ci',
    'persistent' => false,  //是否使用长连接
    );
if( extension_loaded('pdo_mysql') ){
    $_config['MagicDB']['options'] = array(
            PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true,
        ); //额外选项
}


$query = 'select * from test222';

//得到数据库对像事例;
$db = DB::getInstance()->db;
$re = $db->query($query);
var_dump( $re->fetchAll() );

// 更简单的方法
var_export( DB::getOne($query) );  //输出第一行信息(一维数组)
var_export( DB::getAll($query) );  //数出所有信息(多维数组)

?>
